#include "stdafx.h"
#include "Time.h"
#include <ctime>

/*static*/ const float Time::timeToOneTick = (clock() * CLOCKS_PER_SEC) / 1000.f;

Time::Time(unsigned long long ticks) 
{
	this->tick = ticks;
}

/*static*/ Time Time::fromMilliseconds(float v)
{
	return Time(unsigned long long(v * timeToOneTick));
}

/*static*/ Time Time::fromSeconds(float v)
{
	return fromMilliseconds(v / 1000.f);
}

/*static*/ Time Time::fromMinutes(float v)
{
	return fromSeconds(v * 60.f);
}

/*static*/ Time Time::fromHours(float v)
{
	return fromMinutes(v * 60.f);
}

/*static*/ Time Time::fromDays(float v)
{
	return fromHours(v * 24.f);
}

Time Time::operator +(Time& other)
{
	return Time(tick + other.tick);
}

Time Time::operator -(Time& other)
{
	return Time(tick - other.tick);
}